﻿@model SchoolCommunicationSystem.Models.ClassAndSchoolModels

@{
    ViewBag.Title = "Danh sách lớp học";
}
@Scripts.Render("~/bundles/tablesorter")
@Scripts.Render("~/bundles/tablesorterpaging")
<script type="text/javascript">
    $(function () {

        $("table")
            .tablesorter({
                widthFixed: true, widgets: ['zebra'], headers: { 4: { sorter: false },5: { sorter: false } }
            })
        .tablesorterPager({ container: $("#pagersorter") });
    });

</script>
<script>
    $(document).ready(function () {
        $("#schoolYearIDList").change(function () {
            var selection = $("#schoolYearIDList").val();
            var href = $(this).attr('href');
            //Change text
            //     href.replace

            //Change href
            link.attr("href", "linkHref" + selection)
        });
    });
</script>
<div id="page-heading">
    <h1>Quản lý lớp học</h1>
</div>
<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4>Danh sách lớp học</h4>
                </div>
                <div class="panel-body">
                    <div class="module_contentwithsearch">
                        @using (Html.BeginForm("ClassList", "Class", FormMethod.Post, new { @class = "form-horizontal" }))
                        { 
                            <div class="form-group" style="margin-bottom: 0px;">
                                @Html.Label("Năm học:", new { @class = "col-sm-1", @style = "width: 8%;" })
                                <div class="col-sm-2">
                                    @Html.DropDownListFor(model => model.schoolYearIDList, Model.SchoolYearSelectList, new { @class = "form-control" ,@style="padding:2px 5px;"})
                                </div>
                                <div class="col-sm-3">
                                    <button class="btn-primary btn searchbtn" type="submit" style="padding: 4px 15px; font-size: 13px; font-weight: 500;">Tìm kiếm</button>
                                </div>
                            </div>
                        }
                    </div>

                    <div class="module_contentresult">
                        <br />
                        <table class="tablesorter">
                            <thead>
                                <tr>
                                    <th class="sortInitialOrder-desc"style="width:15%;">Tên Lớp</th>
                                      <th style="width:15%;">Năm học</th>
                                      <th style="width:30%;">Ngày Bắt Đầu</th>
                                      <th style="width:30%;">Giáo Viên chủ nhiệm</th>
                                      <th style="width:5%;">Sửa</th>
                                      <th style="width:5%;">Xóa</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var item in Model.Classinschoolyear)
                                {
                                    <tr>
                                        <td>@item.className</td>
                                        <td>@item.SchoolYear.schoolYearName</td>
                                        <td>@Html.FormatValue(item.Class.startDate, "{0:dd/MM/yyyy}")</td>
                                        @if (item.Class.teacherID != null)
                                        {
                                            <td>@item.Class.Teacher.teacherName</td>
                                        }
                                        else
                                        {
                                            <td></td>
                                        }


                                         <td style="text-align: center; align-content: center;align-items:center;">
                                            <a class="editDialog" href="@Url.Action("UpdateClass", "Class", new { id = item.Class.classID, schoolyearID = Model.schoolYearIDList })"><i class="fa fa-pencil"></i></a>
                                        </td>
                                         <td style="text-align: center; align-content: center;align-items:center;">
                                            <a class="editDialog" href="@Url.Action("DeleteClass", "Class", new { id = item.Class.classID, schoolyearID = Model.schoolYearIDList })"><i class="fa fa-times"></i></a>
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        <div id="pagersorter" class="pagersorter">
                            <form class="form-horizontal">
                                <img src="../../Content/images/first.png" class="first" />
                                <img src="../../Content/images/prev.png" class="prev" />
                                <input type="text" class="pagedisplay" />
                                <img src="../../Content/images/next.png" class="next" />
                                <img src="../../Content/images/last.png" class="last" />
                                <select class="pagesize">
                                    <option selected="selected" value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                    <option value="40">40</option>
                                </select>
                            </form>
                        </div>

                        <div style="color: Green; font-weight: bold">
                            @TempData["msg"]
                        </div>
                        <div id="dialog-confirm" style="display: none">
                            <p>
                                <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
                                Bạn có muốn xóa ko ?
                            </p>
                        </div>
                        <div id="dialog-edit" style="display: none">
                        </div>
                        <div id="dialog-view" style="display: none">
                        </div>
                </div>
            </div>
        </div>
    </div>
</div>
    </div>